package com.augurit.gzcgwsp.ywcmn.dao;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.augurit.common.base.dao.BaseDao;
import com.augurit.gzcgwsp.ywcmn.entity.CertificateNo;
@Repository
public class CertificateNoDao extends BaseDao<CertificateNo, Long> {
	
	/**
	 * 获取最大记录数
	 * @param year
	 * @return
	 */
	public Long getMaxNum(int type){
		Long maxnum = 0L;
		String hql = "select count(id) from "+CertificateNo.class.getName()+" where zstype= '" + type +"'";
		List<Long> list = this.find(hql);
		if(list != null && list.size()>0){
		    maxnum = list.get(0);
		}
		return maxnum;
	}

	/**
	 * 根据案件id和类型查询证书编号
	 * @param ajid
	 * @param type
	 * @return
	 */
    public CertificateNo getNo(Long ajid, int type) {
        CertificateNo entity=null;
        String hql = " from "+CertificateNo.class.getName()+" where ajid='"+ajid+"' and zstype= '" + type +"'";
        List<CertificateNo> list = this.find(hql);
        if(list != null && list.size()>0){
            entity = list.get(0);
        }
        return entity;
    }
	
	
	

}